﻿<navigation:Page
           xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           x:Class="LEEAAttendanceControl.Views.Companies" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:my="clr-namespace:LEEAAttendanceControl.Web.Services"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Companies Page">
    <Grid x:Name="LayoutRoot" Margin="2">

        <ScrollViewer BorderThickness="0"  VerticalScrollBarVisibility="Auto" Padding="12,0,12,0" Margin="-12">
            <StackPanel Margin="0,12,0,12" Orientation="Vertical" >
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Margin="0,16,0,0">
                    <HyperlinkButton x:Name="ImgNewCompany" Margin="4" Height="25" Width="21"  Grid.RowSpan="3"
                                     Click="ImgNewCompany_Click">
                        <HyperlinkButton.Background>
                            <ImageBrush ImageSource="/LEEAAttendanceControl;component/Images/create.png" />
                        </HyperlinkButton.Background>
                    </HyperlinkButton>
                    <StackPanel.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FFF6F7F8" Offset="0.372" />
                            <GradientStop Color="#00807F76" Offset="1" />
                        </LinearGradientBrush>
                    </StackPanel.Background>
                </StackPanel>


                <riaControls:DomainDataSource Name="CompanyDataSource" LoadSize="20" QueryName="GetCompanies" AutoLoad="True" PageSize="5" LoadingData="CompanyDataSource_LoadingData">
                    <riaControls:DomainDataSource.DomainContext>
                        <my:LEEAContext />
                    </riaControls:DomainDataSource.DomainContext>
                    <riaControls:DomainDataSource.SortDescriptors>
                        <riaControls:SortDescriptor PropertyPath="CompanyID" Direction="Ascending" />
                    </riaControls:DomainDataSource.SortDescriptors>
                </riaControls:DomainDataSource>

                <sdk:DataPager Name="CompanyPager" Source="{Binding Data, ElementName=CompanyDataSource}"  PageSize="5" Margin="0,-1,0,0"></sdk:DataPager>

                <sdk:DataGrid Name="GRDCompany" AutoGenerateColumns="False"  IsReadOnly="True" Height="Auto"
                              ItemsSource="{Binding Data, ElementName=CompanyDataSource}" HeadersVisibility="All"
                              VerticalContentAlignment="Stretch">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTemplateColumn CanUserReorder="True" Header="Company Id" CanUserResize="True" CanUserSort="True" >
                            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate >
                                    <sdk:Label HorizontalAlignment="Left" Margin="10,10,0,0" Name="lblCompanyId" Content="{Binding CompanyID}" VerticalAlignment="Top" />
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellEditingTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn CanUserReorder="True" Header="Company Name" CanUserResize="True" CanUserSort="True" Width="Auto" >
                            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate >
                                    <sdk:Label  HorizontalAlignment="Left" Margin="10,10,0,0" Name="lblCompanyName" Content="{Binding CompanyName}" VerticalAlignment="Top" />
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellEditingTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn CanUserReorder="True" Header="Address(1)" CanUserResize="True" CanUserSort="True" Width="Auto" >
                            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate >
                                    <sdk:Label HorizontalAlignment="Left" Margin="10,10,0,0" Name="lblAddress1" Content="{Binding Adr1}" VerticalAlignment="Top" />
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellEditingTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn CanUserReorder="True" Header="Country" CanUserResize="True" CanUserSort="True" Width="Auto" >
                            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate >
                                    <sdk:Label HorizontalAlignment="Left" Margin="10,10,0,0" Name="lblCountry" Content="{Binding Country}" VerticalAlignment="Top" />
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellEditingTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn CanUserReorder="True" Header="Region" CanUserResize="True" CanUserSort="True" Width="Auto" >
                            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate >
                                    <sdk:Label HorizontalAlignment="Left" Margin="10,10,0,0" Name="lblRegion" Content="{Binding Region}" VerticalAlignment="Top" />
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellEditingTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn CanUserReorder="True" Header="City" CanUserResize="True" CanUserSort="True" Width="Auto" >
                            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate >
                                    <sdk:Label HorizontalAlignment="Left" Margin="10,10,0,0" Name="lblCity" Content="{Binding City}" VerticalAlignment="Top" />
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellEditingTemplate>
                        </sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn CanUserReorder="True"  CanUserResize="True" CanUserSort="True" Header="Edit" Width="Auto" >
                            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate >
                                    <HyperlinkButton x:Name="LnkEditCompany" Margin="4" Height="25" Width="21"  Grid.RowSpan="3" Click="LnkEditCompany_Click">
                                        <HyperlinkButton.Background>
                                            <ImageBrush ImageSource="/LEEAAttendanceControl;component/Images/edit.png" />
                                        </HyperlinkButton.Background>
                                    </HyperlinkButton>
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellEditingTemplate>
                        </sdk:DataGridTemplateColumn>

                        <sdk:DataGridTemplateColumn CanUserReorder="True"  CanUserResize="True" CanUserSort="True" Header="Delete" Width="Auto" >
                            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate >
                                    <HyperlinkButton x:Name="LnkDeleteCompany" Margin="4" Height="25" Width="21"  Grid.RowSpan="3" Click="LnkDeleteCompany_Click">
                                        <HyperlinkButton.Background>
                                            <ImageBrush ImageSource="/LEEAAttendanceControl;component/Images/delete.png" />
                                        </HyperlinkButton.Background>
                                    </HyperlinkButton>

                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellEditingTemplate>
                        </sdk:DataGridTemplateColumn>
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</navigation:Page>
